import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'
// import Homes from '../views/Homes.vue'
// import Roll from '../views/roll.vue'
import Lucky from "../views/Lucky.vue"
import Shear from "../views/Shear.vue"
import Fight from "../views/Fight.vue"
import ShopMall from "../views/ShopMall.vue"
import OpenBlind from "../views/OpenBlind.vue"
import User from "../views/Usercent/User.vue"
import UserIndex from "../views/Usercent/UserIndex.vue"
import MyBackpack from "../views/Usercent/MyBackpack.vue"
import AccountRecharge from "../views/Usercent/AccountRecharge.vue"
import AccountRechargeRecords from "../views/Usercent/AccountRechargeRecords.vue"
import Share from "../views/Usercent/Share.vue"
import Clause from "../views/Clause.vue"
import Privacy from "../views/Privacy.vue"
import Openlicky from "../views/Openlicky.vue"
import RollRoom from "../views/RollRoom.vue"

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({
    linkActiveClass: 'open activ',
    // mode: 'history',
    routes: [{
            path: '/',
            name: 'Home',
            component: resolve => require(['@/views/Home'], resolve),
            redirect: 'Homes',
            children: [{
                    path: 'roll',
                    name: 'Roll',
                    component: resolve => require(['@/views/Roll'], resolve)
                },
                {
                    path: 'homes',
                    name: 'Homes',
                    component: resolve => require(['@/views/Homes'], resolve)
                },
                {
                    path: 'lucky',
                    component: resolve => require(['@/views/Lucky'], resolve)
                },
                {
                    path: 'shear',
                    component: resolve => require(['@/views/Shear'], resolve)
                },
                {
                    path: 'fight',
                    component: resolve => require(['@/views/Fight'], resolve)
                },
                {
                    path: 'shopmall',
                    component: resolve => require(['@/views/ShopMall'], resolve)
                },
                {
                    path: 'openblind/:id',
                    component: resolve => require(['@/views/OpenBlind'], resolve)
                },
                {
                    path: 'openlicky/:id',
                    component: resolve => require(['@/views/Openlicky'], resolve)
                },
                {
                    path: 'rollroom',
                    component: resolve => require(['@/views/RollRoom'], resolve)
                },
                {
                    path: 'clause',
                    name: 'Clause',
                    component: resolve => require(['@/views/Clause'], resolve)
                },
                {
                    path: 'privacy',
                    name: 'Privacy',
                    component: resolve => require(['@/views/Privacy'], resolve)
                },
                {
                    path: '/user',
                    component: resolve => require(['@/views/Usercent/User'], resolve),
                    name: 'User',
                    redirect: 'UserIndex',
                    children: [{
                            path: '/',
                            component: resolve => require(['@/views/Usercent/UserIndex'], resolve)
                        },
                        {
                            path: '/mybackpack',
                            component: resolve => require(['@/views/Usercent/MyBackpack'], resolve)
                        },
                        {
                            path: '/accountrecharge',
                            component: resolve => require(['@/views/Usercent/AccountRecharge'], resolve)
                        },
                        {
                            path: '/accountrechargerecords',
                            component: resolve => require(['@/views/Usercent/AccountRechargeRecords'], resolve)
                        },
                        {
                            path: '/Share',
                            component: resolve => require(['@/views/Usercent/Share'], resolve)
                        },
                    ]
                }
            ]
        },
        {
            path: '/three',
            name: 'three',
            component: () =>
                import ('../views/three')
        }
    ],
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) { return savedPosition; } else { return { x: 0, y: 0 } }
    },
})